* Change to directory with files*
use "cyk_main_experiments_combined.dta", clear
* Scheme graphs were made in *
set scheme s2color

* Treatment Effects *
* Figure 1: Treatment Effects across all 10 Experiments *
reg support i.exp_group 
margins, dydx(*)
marginsplot, horizontal graphregion(color(white)) ti("") yscale(range(.5 2.5)) yti("") xti(" " "Difference in Support") ylabel(1 "Zone 3 Treatment" 2 "Zone 1 Treatment") recast(scatter) recastci(rspike) plotopts(mcolor(black)) ciopts(lcolor(black)) xline(0) xlabel(-.06 "-6%" -.04 "-4%" -.02 "-2%" 0 "0%" .02 "2%" .04 "4%" .06 "6%") saving("effects_all.gph", replace)
* test referenced in text *
ttest support if treat_zone1 == 1|treat_zone3 == 1, by(treat_zone1)

* Figure 2: Treatment effects by category *
use "cyk_main_experiments_combined.dta", clear
gen n = _n
gen diff = .
gen l = .
gen u = .
gen sediff = .
gen treatment = .

reg support treat_zone1 treat_zone3 if hypothetical == 1
replace diff = _b[treat_zone1] if n == 6
replace sediff = _se[treat_zone1] if n == 6
replace treatment = 1 if n == 6
replace diff = _b[treat_zone3] if n == 5
replace sediff = _se[treat_zone3] if n == 5
replace treatment = 0 if n == 5
reg support control treat_zone1 if hypothetical == 1
replace diff = _b[treat_zone1] if n == 4
replace sediff = _se[treat_zone1] if n == 4
replace treatment = 3 if n == 4

reg support treat_zone1 treat_zone3 if distant == 1
replace diff = _b[treat_zone1] if n == 3
replace sediff = _se[treat_zone1] if n == 3
replace treatment = 1 if n == 3
replace diff = _b[treat_zone3] if n == 2
replace sediff = _se[treat_zone3] if n == 2
replace treatment = 0 if n == 2
reg support control treat_zone1 if distant == 1
replace diff = _b[treat_zone1] if n == 1
replace sediff = _se[treat_zone1] if n == 1
replace treatment = 3 if n == 1

reg support treat_zone1 treat_zone3 if recent == 1
replace diff = _b[treat_zone1] if n == 9
replace sediff = _se[treat_zone1] if n == 9
replace treatment = 1 if n == 9
replace diff = _b[treat_zone3] if n == 8
replace sediff = _se[treat_zone3] if n == 8
replace treatment = 0 if n == 8
reg support control treat_zone1 if recent == 1
replace diff = _b[treat_zone1] if n == 7
replace sediff = _se[treat_zone1] if n == 7
replace treatment = 3 if n == 7

replace l = diff-1.96*(sediff)
replace u = diff+1.96*(sediff)
replace n = . if n > 9
recode n (1=1.7) (3=2.3) (4=4.7) (6=5.3) (7=7.7) (9=8.33) 
twoway (dot  diff n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  diff n if treatment == 0, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  diff n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(circle_hollow) color(gs5)) ///
(rspike u l n if treatment ==0|treatment==1, horizontal color(black)) ///
(rspike u l n if treatment ==3, horizontal color(gs5)), yti("") graphregion(color(white)) ///
xline(0) xlabel(-.1 "-10%" -.05 "-5%" 0 "0%" .05 "5%" .1 "10%" .15 "15%") xline(0) ///
ylabel( 2 "Clinton or Bush" 8 "Biden or Trump" 5 "Hypothetical", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment" 3 "Zone 1 - Zone 3") size(small) keygap(3) symx(.85) cols(3))   yscale(range(.5 9.5)) 

* Figure 3: Comparing Hypotheticals *
use "cyk_main_experiments_combined.dta", clear
gen n = _n
gen diff = .
gen l = .
gen u = .
gen sediff = .
gen treatment = .

reg support treat_zone1 treat_zone3 if experiment == 7
replace diff = _b[treat_zone1] if n == 6
replace sediff = _se[treat_zone1] if n == 6
replace treatment = 1 if n == 6
replace diff = _b[treat_zone3] if n == 5
replace sediff = _se[treat_zone3] if n == 5
replace treatment = 0 if n == 5
reg support control treat_zone1 if experiment == 7
replace diff = _b[treat_zone1] if n == 4
replace sediff = _se[treat_zone1] if n == 4
replace treatment = 3 if n == 4

reg support treat_zone1 treat_zone3 if experiment == 10
replace diff = _b[treat_zone1] if n == 3
replace sediff = _se[treat_zone1] if n == 3
replace treatment = 1 if n == 3
replace diff = _b[treat_zone3] if n == 2
replace sediff = _se[treat_zone3] if n == 2
replace treatment = 0 if n == 2
reg support control treat_zone1 if experiment == 10
replace diff = _b[treat_zone1] if n == 1
replace sediff = _se[treat_zone1] if n == 1
replace treatment = 3 if n == 1

reg support treat_zone1 treat_zone3 if experiment == 4
replace diff = _b[treat_zone1] if n == 9
replace sediff = _se[treat_zone1] if n == 9
replace treatment = 1 if n == 9
replace diff = _b[treat_zone3] if n == 8
replace sediff = _se[treat_zone3] if n == 8
replace treatment = 0 if n == 8
reg support control treat_zone1 if experiment == 4
replace diff = _b[treat_zone1] if n == 7
replace sediff = _se[treat_zone1] if n == 7
replace treatment = 3 if n == 7

reg support treat_zone1 treat_zone3 if experiment == 3
replace diff = _b[treat_zone1] if n == 12
replace sediff = _se[treat_zone1] if n == 12
replace treatment = 1 if n == 12
replace diff = _b[treat_zone3] if n == 11
replace sediff = _se[treat_zone3] if n == 11
replace treatment = 0 if n == 11
reg support control treat_zone1 if experiment == 3
replace diff = _b[treat_zone1] if n == 10
replace sediff = _se[treat_zone1] if n == 10
replace treatment = 3 if n == 10

replace l = diff-1.96*(sediff)
replace u = diff+1.96*(sediff)
replace n = . if n > 12
recode n (1=1.7) (3=2.3) (4=4.7) (6=5.3) (7=7.7) (9=8.3)  (10=10.7) (12=11.3)
twoway (dot  diff n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  diff n if treatment == 0, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  diff n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(circle_hollow) color(gs5)) ///
(rspike u l n if treatment ==0|treatment==1, horizontal color(black)) ///
(rspike u l n if treatment ==3, horizontal color(gs5)), yti("") graphregion(color(white)) ///
xline(0) xlabel(-.15 "15%" -.1 "-10%" -.05 "-5%" 0 "0%" .05 "5%" .1 "10%" .15 "15%" .2 "20%") xline(0) ///
ylabel( 8 `" "Hypothetical Mexico Loan" "(Unilateral Control)" "' 5 `" "Hypothetical Mexico Loan" "(Legislative Control)" "' 2 "Hypothetical Student Loans" 11 "Hypothetical Platinum Coin", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment" 3 "Zone 1 - Zone 3") size(small) keygap(2) symx(.85) cols(3))   yscale(range(.5 12.5)) 

* Rule of Law Moderation *
* Figure 4: ROL Moderation across all 10 Experiments *
logit support i.treat_zone1##c.rule_of_law gop5 dem5 female age education white rule_of_law if exp_group !=1
margins, dydx(treat_zone1) at(rule_of_law=(1(.1)4) gop5=0 dem5=0 female=1 education =3 age=43 white = 1 rule_of_law=3)
marginsplot, recast(line) recastci(rarea) ti("") ///
xtitle("Rule of Law Index") graphregion(color(white)) yline(0, lpattern(dash)) ci1opts(color(gs10%70)) plotopts(lcolor(black)) yti("Zone1 vs. Zone 3" " ") saving("rol_all.gph", replace)

* Figure 5: Rule of Law Moderation by Category *
logit support i.treat_zone1##c.rule_of_law gop5 dem5 female age education white rule_of_law if exp_group !=1 & recent == 1
margins, dydx(treat_zone1) at(rule_of_law=(1(.1)4))
marginsplot, recast(line) recastci(rarea) ti("Biden or Trump") ///
xtitle("Rule of Law Index") graphregion(color(white)) yline(0, lpattern(dash)) ci1opts(color(gs10%70)) plotopts(lcolor(black)) yti("Zone1 vs. Zone 3" " ") saving("rol_recent.gph", replace) ylabel(-.1 0 .1 .2)

logit support i.treat_zone1##c.rule_of_law gop5 dem5 female age education white rule_of_law if exp_group !=1 & hypothetical == 1
margins, dydx(treat_zone1) at(rule_of_law=(1(.1)4))
marginsplot, recast(line) recastci(rarea) ti("Hypothetical") ///
xtitle("Rule of Law Index") graphregion(color(white)) yline(0, lpattern(dash)) ci1opts(color(gs10%70)) plotopts(lcolor(black)) yti("Zone1 vs. Zone 3" " ") saving("rol_hypothetical.gph", replace) ylabel(-.1 0 .1 .2)

logit support i.treat_zone1##c.rule_of_law gop5 dem5 female age education white rule_of_law if exp_group !=1 & distant == 1
margins, dydx(treat_zone1) at(rule_of_law=(1(.1)4))
marginsplot, recast(line) recastci(rarea) ti("Clinton or Bush") ///
xtitle("Rule of Law Index") graphregion(color(white)) yline(0, lpattern(dash)) ci1opts(color(gs10%70)) plotopts(lcolor(black)) yti("Zone1 vs. Zone 3" " ") saving("rol_distant.gph", replace) ylabel(-.1 0 .1 .2)
graph combine "rol_recent.gph" "rol_hypothetical.gph" "rol_distant.gph", graphregion(color(white)) rows(3) xsize(8.5) ysize(11)

* Partisan Moderation *
* Figure 6: Effects by Party *
* Hypothetical Coin *
use  "cyk_first_survey_data_combined.dta", clear
gen party3 = .
replace party3=1 if dem5==1
replace party3 = 2 if dem5 == 0 & gop5 == 0
replace party3 = 3 if gop5 == 1
keep if experiment == 3
gen hypcoin_condition = .
replace hypcoin_condition = 1 if treat_zone1 == 0 & treat_zone3==0
replace hypcoin_condition = 2 if treat_zone1 == 1
replace hypcoin_condition = 3 if treat_zone3 == 1
gen hyp_coin_support = support
logit hyp_coin_support i.hypcoin_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) hypcoin_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)  post
margins, coeflegend
* Test Democrats delegation vs. contra Congress *
test _b[4._at] = _b[7._at]
* Test Independents delegation vs. contra Congress *
test _b[5._at] = _b[8._at]
* Test Republicans delegation vs. contra Congress *
test _b[6._at] = _b[9._at]

logit hyp_coin_support i.hypcoin_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) hypcoin_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)
matrix results = r(table)
matrix list results

gen n = _n
gen point = .
gen l = .
gen u = .
gen party = .
gen treatment = .

local a = results[1,1]
replace point = results[1,4] if n == 8
replace l = results[5,4] if n == 8
replace u = results[6,4] if n == 8
replace treatment = 1 if n == 8

replace point = results[1,7] if n == 7
replace l = results[5,7] if n == 7
replace u = results[6,7] if n == 7
replace treatment = 2 if n == 7

local b = results[1,2]
replace point = results[1,5] if n == 5
replace l = results[5,5] if n == 5
replace u = results[6,5] if n == 5
replace treatment = 1 if n == 5

replace point = results[1,8] if n == 4
replace l = results[5,8] if n == 4
replace u = results[6,8] if n == 4
replace treatment = 2 if n == 4

local c = results[1,3]
replace point = results[1,6] if n == 2
replace l = results[5,6] if n == 2
replace u = results[6,6] if n == 2
replace treatment = 1 if n == 2

replace point = results[1,9] if n == 1
replace l = results[5,9] if n == 1
replace u = results[6,9] if n == 1
replace treatment = 2 if n == 1

drop if n > 8

twoway (dot  point n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  point n if treatment == 2, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  point n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(`a', lcolor(blue)) xline(`b', lpattern(dash) lcolor(black)) xline(`c', lpattern(shortdash)) xlabel(.1 .2 .3 .4 .5 .6 .7 .8 .9)  ///
ylabel(7.5 "Democrats" 4.5 "Independents" 1.5 "Republicans", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment")  size(vsmall) keygap(0) cols(2)) scale(.75) yscale(range(.5 8.5)) ti("Hypothetical Coin") saving(hypcoin_party.gph, replace)

* Biden Coin *
use  "cyk_first_survey_data_combined.dta", clear
gen party3 = .
replace party3=1 if dem5==1
replace party3 = 2 if dem5 == 0 & gop5 == 0
replace party3 = 3 if gop5 == 1

keep if experiment == 2

gen bidencoin_condition = .
replace bidencoin_condition = 1 if treat_zone1 == 0 & treat_zone3==0
replace bidencoin_condition = 2 if treat_zone1 == 1
replace bidencoin_condition = 3 if treat_zone3 == 1
gen biden_coin_support = support

logit biden_coin_support i.bidencoin_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) bidencoin_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3) post
margins, coeflegend
* Test Democrats delegation vs. contra Congress *
test _b[4._at] = _b[7._at]
* Test Independents delegation vs. contra Congress *
test _b[5._at] = _b[8._at]
* Test Republicans delegation vs. contra Congress *
test _b[6._at] = _b[9._at] 

logit biden_coin_support i.bidencoin_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) bidencoin_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)
matrix results = r(table)
matrix list results

gen n = _n
gen point = .
gen l = .
gen u = .
gen party = .
gen treatment = .

local a = results[1,1]
replace point = results[1,4] if n == 8
replace l = results[5,4] if n == 8
replace u = results[6,4] if n == 8
replace treatment = 1 if n == 8

replace point = results[1,7] if n == 7
replace l = results[5,7] if n == 7
replace u = results[6,7] if n == 7
replace treatment = 2 if n == 7

local b = results[1,2]
replace point = results[1,5] if n == 5
replace l = results[5,5] if n == 5
replace u = results[6,5] if n == 5
replace treatment = 1 if n == 5

replace point = results[1,8] if n == 4
replace l = results[5,8] if n == 4
replace u = results[6,8] if n == 4
replace treatment = 2 if n == 4

local c = results[1,3]
replace point = results[1,6] if n == 2
replace l = results[5,6] if n == 2
replace u = results[6,6] if n == 2
replace treatment = 1 if n == 2

replace point = results[1,9] if n == 1
replace l = results[5,9] if n == 1
replace u = results[6,9] if n == 1
replace treatment = 2 if n == 1

drop if n > 8

twoway (dot  point n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  point n if treatment == 2, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  point n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(`a', lcolor(blue)) xline(`b', lpattern(dash) lcolor(black)) xline(`c', lpattern(shortdash)) xlabel(.1 .2 .3 .4 .5 .6 .7 .8 .9) ///
ylabel(7.5 "Democrats" 4.5 "Independents" 1.5 "Republicans", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment")  size(vsmall) keygap(0) cols(2)) scale(.75) yscale(range(.5 8.5)) ti("Biden Coin") saving(bidencoin_party.gph, replace)

* Bush Tribunals *
use  "cyk_first_survey_data_combined.dta", clear
gen party3 = .
replace party3=1 if dem5==1
replace party3 = 2 if dem5 == 0 & gop5 == 0
replace party3 = 3 if gop5 == 1

keep if experiment == 6

gen bushtribunals_condition = .
replace bushtribunals_condition = 1 if treat_zone1 == 0 & treat_zone3==0
replace bushtribunals_condition = 2 if treat_zone1 == 1
replace bushtribunals_condition = 3 if treat_zone3 == 1
gen tribunals_support = support

logit tribunals_support i.bushtribunals_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) bushtribunals_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)  post
margins, coeflegend
* Test Democrats delegation vs. contra Congress *
test _b[4._at] = _b[7._at]
* Test Independents delegation vs. contra Congress *
test _b[5._at] = _b[8._at]
* Test Republicans delegation vs. contra Congress *
test _b[6._at] = _b[9._at]

logit tribunals_support i.bushtribunals_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) bushtribunals_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)
matrix results = r(table)
matrix list results

gen n = _n
gen point = .
gen l = .
gen u = .
gen party = .
gen treatment = .

local a = results[1,1]
replace point = results[1,4] if n == 8
replace l = results[5,4] if n == 8
replace u = results[6,4] if n == 8
replace treatment = 1 if n == 8

replace point = results[1,7] if n == 7
replace l = results[5,7] if n == 7
replace u = results[6,7] if n == 7
replace treatment = 2 if n == 7

local b = results[1,2]
replace point = results[1,5] if n == 5
replace l = results[5,5] if n == 5
replace u = results[6,5] if n == 5
replace treatment = 1 if n == 5

replace point = results[1,8] if n == 4
replace l = results[5,8] if n == 4
replace u = results[6,8] if n == 4
replace treatment = 2 if n == 4

local c = results[1,3]
replace point = results[1,6] if n == 2
replace l = results[5,6] if n == 2
replace u = results[6,6] if n == 2
replace treatment = 1 if n == 2

replace point = results[1,9] if n == 1
replace l = results[5,9] if n == 1
replace u = results[6,9] if n == 1
replace treatment = 2 if n == 1

drop if n > 8

twoway (dot  point n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  point n if treatment == 2, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  point n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(`a', lcolor(blue)) xline(`b', lpattern(dash) lcolor(black)) xline(`c', lpattern(shortdash)) xlabel(.1 .2 .3 .4 .5 .6 .7 .8 .9)  ///
ylabel(7.5 "Democrats" 4.5 "Independents" 1.5 "Republicans", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment") size(vsmall) keygap(0) cols(2)) scale(.75) yscale(range(.5 8.5)) ti("Bush Tribunals") saving(tribunals_party.gph, replace)

* Trump Wall *
use  "cyk_first_survey_data_combined.dta", clear
gen party3 = .
replace party3=1 if dem5==1
replace party3 = 2 if dem5 == 0 & gop5 == 0
replace party3 = 3 if gop5 == 1

keep if experiment == 1

gen wall_condition = .
replace wall_condition = 1 if treat_zone1 == 0 & treat_zone3==0
replace wall_condition = 2 if treat_zone1 == 1
replace wall_condition = 3 if treat_zone3 == 1
gen wall_support = support

logit wall_support i.wall_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) wall_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)  post
margins, coeflegend
* Test Democrats delegation vs. contra Congress *
test _b[4._at] = _b[7._at]
* Test Independents delegation vs. contra Congress *
test _b[5._at] = _b[8._at]
* Test Republicans delegation vs. contra Congress *
test _b[6._at] = _b[9._at]

logit wall_support i.wall_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) wall_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3) 
matrix results = r(table)
matrix list results

gen n = _n
gen point = .
gen l = .
gen u = .
gen party = .
gen treatment = .

local a = results[1,1]
replace point = results[1,4] if n == 8
replace l = results[5,4] if n == 8
replace u = results[6,4] if n == 8
replace treatment = 1 if n == 8

replace point = results[1,7] if n == 7
replace l = results[5,7] if n == 7
replace u = results[6,7] if n == 7
replace treatment = 2 if n == 7

local b = results[1,2]
replace point = results[1,5] if n == 5
replace l = results[5,5] if n == 5
replace u = results[6,5] if n == 5
replace treatment = 1 if n == 5

replace point = results[1,8] if n == 4
replace l = results[5,8] if n == 4
replace u = results[6,8] if n == 4
replace treatment = 2 if n == 4

local c = results[1,3]
replace point = results[1,6] if n == 2
replace l = results[5,6] if n == 2
replace u = results[6,6] if n == 2
replace treatment = 1 if n == 2

replace point = results[1,9] if n == 1
replace l = results[5,9] if n == 1
replace u = results[6,9] if n == 1
replace treatment = 2 if n == 1

drop if n > 8

twoway (dot  point n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  point n if treatment == 2, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  point n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(`a', lcolor(blue)) xline(`b', lpattern(dash) lcolor(black)) xline(`c', lpattern(shortdash)) xlabel(.1 .2 .3 .4 .5 .6 .7 .8 .9)  ///
ylabel(7.5 "Democrats" 4.5 "Independents" 1.5 "Republicans", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment")  size(vsmall) keygap(0) cols(2)) scale(.75) yscale(range(.5 8.5)) ti("Trump Wall") saving(wall_party.gph, replace)

* Clinton Mexico Loan *
use  "cyk_first_survey_data_combined.dta", clear

gen party3 = .
replace party3=1 if dem5==1
replace party3 = 2 if dem5 == 0 & gop5 == 0
replace party3 = 3 if gop5 == 1

keep if experiment == 5

gen clinton_loan_condition = .
replace clinton_loan_condition = 1 if treat_zone1 == 0 & treat_zone3==0
replace clinton_loan_condition = 2 if treat_zone1 == 1
replace clinton_loan_condition = 3 if treat_zone3 == 1
gen clinton_loan_support = support

logit clinton_loan_support i.clinton_loan_condition##i.party3 female age education white rule_of_law 
margins, at(party3=(1 (1) 3) clinton_loan_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)  post
margins, coeflegend
* Test Democrats delegation vs. contra Congress *
test _b[4._at] = _b[7._at]
* Test Independents delegation vs. contra Congress *
test _b[5._at] = _b[8._at]
* Test Republicans delegation vs. contra Congress *
test _b[6._at] = _b[9._at]

logit clinton_loan_support i.clinton_loan_condition##i.party3 female age education white rule_of_law 
margins, at(party3=(1 (1) 3) clinton_loan_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)
matrix results = r(table)
matrix list results

gen n = _n
gen point = .
gen l = .
gen u = .
gen party = .
gen treatment = .

local a = results[1,1]
replace point = results[1,4] if n == 8
replace l = results[5,4] if n == 8
replace u = results[6,4] if n == 8
replace treatment = 1 if n == 8

replace point = results[1,7] if n == 7
replace l = results[5,7] if n == 7
replace u = results[6,7] if n == 7
replace treatment = 2 if n == 7

local b = results[1,2]
replace point = results[1,5] if n == 5
replace l = results[5,5] if n == 5
replace u = results[6,5] if n == 5
replace treatment = 1 if n == 5

replace point = results[1,8] if n == 4
replace l = results[5,8] if n == 4
replace u = results[6,8] if n == 4
replace treatment = 2 if n == 4

local c = results[1,3]
replace point = results[1,6] if n == 2
replace l = results[5,6] if n == 2
replace u = results[6,6] if n == 2
replace treatment = 1 if n == 2

replace point = results[1,9] if n == 1
replace l = results[5,9] if n == 1
replace u = results[6,9] if n == 1
replace treatment = 2 if n == 1

drop if n > 8

twoway (dot  point n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  point n if treatment == 2, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  point n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(`a', lcolor(blue)) xline(`b', lpattern(dash) lcolor(black)) xline(`c', lpattern(shortdash)) xlabel(.1 .2 .3 .4 .5 .6 .7 .8 .9)  ///
ylabel(7.5 "Democrats" 4.5 "Independents" 1.5 "Republicans", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment")  size(vsmall) keygap(0) cols(2)) scale(.75) yscale(range(.5 8.5)) ti("Clinton Mexico Loan") saving(clinton_party_noinfo.gph, replace)

* Hypothetical Mexico *
use  "cyk_first_survey_data_combined.dta", clear

gen party3 = .
replace party3=1 if dem5==1
replace party3 = 2 if dem5 == 0 & gop5 == 0
replace party3 = 3 if gop5 == 1

gen hyp_loan_condition = .
replace hyp_loan_condition = 1 if treat_zone1 == 0 & treat_zone3==0
replace hyp_loan_condition = 2 if treat_zone1 == 1
replace hyp_loan_condition = 3 if treat_zone3 == 1
gen hyp_loan_support = support

logit hyp_loan_support i.hyp_loan_condition##i.party3 female age education white rule_of_law if experiment == 4
margins, at(party3=(1 (1) 3) hyp_loan_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)  post
margins, coeflegend
* Test Democrats delegation vs. contra Congress *
test _b[4._at] = _b[7._at]
* Test Independents delegation vs. contra Congress *
test _b[5._at] = _b[8._at]
* Test Republicans delegation vs. contra Congress *
test _b[6._at] = _b[9._at]

logit hyp_loan_support i.hyp_loan_condition##i.party3 female age education white rule_of_law if experiment == 4
margins, at(party3=(1 (1) 3) hyp_loan_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)
matrix results = r(table)
matrix list results

gen n = _n
gen point = .
gen l = .
gen u = .
gen party = .
gen treatment = .

local a = results[1,1]
replace point = results[1,4] if n == 8
replace l = results[5,4] if n == 8
replace u = results[6,4] if n == 8
replace treatment = 1 if n == 8

replace point = results[1,7] if n == 7
replace l = results[5,7] if n == 7
replace u = results[6,7] if n == 7
replace treatment = 2 if n == 7

local b = results[1,2]
replace point = results[1,5] if n == 5
replace l = results[5,5] if n == 5
replace u = results[6,5] if n == 5
replace treatment = 1 if n == 5

replace point = results[1,8] if n == 4
replace l = results[5,8] if n == 4
replace u = results[6,8] if n == 4
replace treatment = 2 if n == 4

local c = results[1,3]
replace point = results[1,6] if n == 2
replace l = results[5,6] if n == 2
replace u = results[6,6] if n == 2
replace treatment = 1 if n == 2

replace point = results[1,9] if n == 1
replace l = results[5,9] if n == 1
replace u = results[6,9] if n == 1
replace treatment = 2 if n == 1

drop if n > 8

twoway (dot  point n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  point n if treatment == 2, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  point n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(`a', lcolor(blue)) xline(`b', lpattern(dash) lcolor(black)) xline(`c', lpattern(shortdash)) xlabel(.1 .2 .3 .4 .5 .6 .7 .8 .9)  ///
ylabel(7.5 "Democrats" 4.5 "Independents" 1.5 "Republicans", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment")  size(vsmall) keygap(0) cols(2)) scale(.75) yscale(range(.5 8.5)) ti("Hypothetical Mexico Loan") saving(hyploan_party_noinfo.gph, replace)

grc1leg2  "wall_party.gph"  "bidencoin_party.gph"  "hyploan_party_noinfo.gph" "hypcoin_party.gph"  "clinton_party_noinfo.gph" "tribunals_party.gph"   , ///
graphregion(color(white)) rows(3) 

* Figure 7: Effects by Party, Follow-up Experiments *
use  "cyk_second_survey_data_combined.dta", clear
* Hypothetical Mexico Loan *
gen party3 = .
replace party3=1 if dem5==1
replace party3 = 2 if dem5 == 0 & gop5 == 0
replace party3 = 3 if gop5 == 1

keep if experiment == 1

gen mexloan_condition = .
replace mexloan_condition = 1 if leg_control == 1
replace mexloan_condition = 2 if treat_zone1 == 1
replace mexloan_condition = 3 if treat_zone3 == 1
gen mexloan_support = support

logit mexloan_support i.mexloan_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) mexloan_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)  post
margins, coeflegend
* Test Democrats delegation vs. contra Congress *
test _b[4._at] = _b[7._at]
* Test Independents delegation vs. contra Congress *
test _b[5._at] = _b[8._at]
* Test Republicans delegation vs. contra Congress *
test _b[6._at] = _b[9._at]

logit mexloan_support i.mexloan_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) mexloan_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)
matrix results = r(table)
matrix list results

gen n = _n
gen point = .
gen l = .
gen u = .
gen party = .
gen treatment = .

local a = results[1,1]
replace point = results[1,4] if n == 8
replace l = results[5,4] if n == 8
replace u = results[6,4] if n == 8
replace treatment = 1 if n == 8

replace point = results[1,7] if n == 7
replace l = results[5,7] if n == 7
replace u = results[6,7] if n == 7
replace treatment = 2 if n == 7

local b = results[1,2]
replace point = results[1,5] if n == 5
replace l = results[5,5] if n == 5
replace u = results[6,5] if n == 5
replace treatment = 1 if n == 5

replace point = results[1,8] if n == 4
replace l = results[5,8] if n == 4
replace u = results[6,8] if n == 4
replace treatment = 2 if n == 4

local c = results[1,3]
replace point = results[1,6] if n == 2
replace l = results[5,6] if n == 2
replace u = results[6,6] if n == 2
replace treatment = 1 if n == 2

replace point = results[1,9] if n == 1
replace l = results[5,9] if n == 1
replace u = results[6,9] if n == 1
replace treatment = 2 if n == 1

drop if n > 8

twoway (dot  point n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  point n if treatment == 2, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  point n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(`a', lcolor(blue)) xline(`b', lpattern(dash) lcolor(black)) xline(`c', lpattern(shortdash)) xlabel(.1 .2 .3 .4 .5 .6 .7 .8 .9)  ///
ylabel(7.5 "Democrats" 4.5 "Independents" 1.5 "Republicans", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment")   size(small) keygap(0) cols(2)) scale(.75) yscale(range(.5 8.5)) ti("Hypothetical Mexico Loan") saving(hyploan_party.gph, replace)

* Clinton Mexico Loan *
use  "cyk_second_survey_data_combined.dta", clear
gen party3 = .
replace party3=1 if dem5==1
replace party3 = 2 if dem5 == 0 & gop5 == 0
replace party3 = 3 if gop5 == 1

keep if experiment == 3

gen clintonloan_condition = .
replace clintonloan_condition = 1 if leg_control == 1
replace clintonloan_condition = 2 if treat_zone1 == 1
replace clintonloan_condition = 3 if treat_zone3 == 1
gen clintonloan_support = support

logit clintonloan_support i.clintonloan_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) clintonloan_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3) post
margins, coeflegend
* Test Democrats delegation vs. contra Congress *
test _b[4._at] = _b[7._at]
* Test Independents delegation vs. contra Congress *
test _b[5._at] = _b[8._at]
* Test Republicans delegation vs. contra Congress *
test _b[6._at] = _b[9._at] 

logit clintonloan_support i.clintonloan_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) clintonloan_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)
matrix results = r(table)
matrix list results

gen n = _n
gen point = .
gen l = .
gen u = .
gen party = .
gen treatment = .

local a = results[1,1]
replace point = results[1,4] if n == 8
replace l = results[5,4] if n == 8
replace u = results[6,4] if n == 8
replace treatment = 1 if n == 8

replace point = results[1,7] if n == 7
replace l = results[5,7] if n == 7
replace u = results[6,7] if n == 7
replace treatment = 2 if n == 7

local b = results[1,2]
replace point = results[1,5] if n == 5
replace l = results[5,5] if n == 5
replace u = results[6,5] if n == 5
replace treatment = 1 if n == 5

replace point = results[1,8] if n == 4
replace l = results[5,8] if n == 4
replace u = results[6,8] if n == 4
replace treatment = 2 if n == 4

local c = results[1,3]
replace point = results[1,6] if n == 2
replace l = results[5,6] if n == 2
replace u = results[6,6] if n == 2
replace treatment = 1 if n == 2

replace point = results[1,9] if n == 1
replace l = results[5,9] if n == 1
replace u = results[6,9] if n == 1
replace treatment = 2 if n == 1

drop if n > 8

twoway (dot  point n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  point n if treatment == 2, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  point n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(`a', lcolor(blue)) xline(`b', lpattern(dash) lcolor(black)) xline(`c', lpattern(shortdash)) xlabel(.1 .2 .3 .4 .5 .6 .7 .8 .9) ///
ylabel(7.5 "Democrats" 4.5 "Independents" 1.5 "Republicans", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment")  size(small) keygap(0) cols(2)) scale(.75) yscale(range(.5 8.5)) ti("Clinton Mexico Loan") saving(clintonloan_party.gph, replace)

* Biden Student Loans *
use  "cyk_second_survey_data_combined.dta", clear
gen party3 = .
replace party3=1 if dem5==1
replace party3 = 2 if dem5 == 0 & gop5 == 0
replace party3 = 3 if gop5 == 1

keep if experiment == 2

gen biden_studentloans_condition = .
replace biden_studentloans_condition = 1 if leg_control == 1
replace biden_studentloans_condition = 2 if treat_zone1 == 1
replace biden_studentloans_condition = 3 if treat_zone3 == 1
gen biden_studentloans_support = support

logit biden_studentloans_support i.biden_studentloans_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) biden_studentloans_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)  post
margins, coeflegend
* Test Democrats delegation vs. contra Congress *
test _b[4._at] = _b[7._at]
* Test Independents delegation vs. contra Congress *
test _b[5._at] = _b[8._at]
* Test Republicans delegation vs. contra Congress *
test _b[6._at] = _b[9._at]

logit biden_studentloans_support i.biden_studentloans_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) biden_studentloans_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)
matrix results = r(table)
matrix list results

gen n = _n
gen point = .
gen l = .
gen u = .
gen party = .
gen treatment = .

local a = results[1,1]
replace point = results[1,4] if n == 8
replace l = results[5,4] if n == 8
replace u = results[6,4] if n == 8
replace treatment = 1 if n == 8

replace point = results[1,7] if n == 7
replace l = results[5,7] if n == 7
replace u = results[6,7] if n == 7
replace treatment = 2 if n == 7

local b = results[1,2]
replace point = results[1,5] if n == 5
replace l = results[5,5] if n == 5
replace u = results[6,5] if n == 5
replace treatment = 1 if n == 5

replace point = results[1,8] if n == 4
replace l = results[5,8] if n == 4
replace u = results[6,8] if n == 4
replace treatment = 2 if n == 4

local c = results[1,3]
replace point = results[1,6] if n == 2
replace l = results[5,6] if n == 2
replace u = results[6,6] if n == 2
replace treatment = 1 if n == 2

replace point = results[1,9] if n == 1
replace l = results[5,9] if n == 1
replace u = results[6,9] if n == 1
replace treatment = 2 if n == 1

drop if n > 8

twoway (dot  point n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  point n if treatment == 2, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  point n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(`a', lcolor(blue)) xline(`b', lpattern(dash) lcolor(black)) xline(`c', lpattern(shortdash)) xlabel(.1 .2 .3 .4 .5 .6 .7 .8 .9)  ///
ylabel(7.5 "Democrats" 4.5 "Independents" 1.5 "Republicans", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment")   size(small) keygap(0) cols(2)) scale(.75) yscale(range(.5 8.5)) ti("Biden Student Loans") saving(biden_studentloans_party.gph, replace)

* Hypothetical Student Loans *
use  "cyk_second_survey_data_combined.dta", clear
gen party3 = .
replace party3=1 if dem5==1
replace party3 = 2 if dem5 == 0 & gop5 == 0
replace party3 = 3 if gop5 == 1

keep if experiment == 4

gen studentloans_condition = .
replace studentloans_condition = 1 if leg_control == 1
replace studentloans_condition = 2 if treat_zone1 == 1
replace studentloans_condition = 3 if treat_zone3 == 1
gen studentloans_support = support

logit studentloans_support i.studentloans_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) studentloans_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)  post
margins, coeflegend
* Test Democrats delegation vs. contra Congress *
test _b[4._at] = _b[7._at]
* Test Independents delegation vs. contra Congress *
test _b[5._at] = _b[8._at]
* Test Republicans delegation vs. contra Congress *
test _b[6._at] = _b[9._at]

logit studentloans_support i.studentloans_condition##i.party3 female age education white rule_of_law
margins, at(party3=(1 (1) 3) studentloans_condition=(1(1)3) rule_of_law = 2.8 female=1 age=44 white=1 education=3)
matrix results = r(table)
matrix list results

gen n = _n
gen point = .
gen l = .
gen u = .
gen party = .
gen treatment = .

local a = results[1,1]
replace point = results[1,4] if n == 8
replace l = results[5,4] if n == 8
replace u = results[6,4] if n == 8
replace treatment = 1 if n == 8

replace point = results[1,7] if n == 7
replace l = results[5,7] if n == 7
replace u = results[6,7] if n == 7
replace treatment = 2 if n == 7

local b = results[1,2]
replace point = results[1,5] if n == 5
replace l = results[5,5] if n == 5
replace u = results[6,5] if n == 5
replace treatment = 1 if n == 5

replace point = results[1,8] if n == 4
replace l = results[5,8] if n == 4
replace u = results[6,8] if n == 4
replace treatment = 2 if n == 4

local c = results[1,3]
replace point = results[1,6] if n == 2
replace l = results[5,6] if n == 2
replace u = results[6,6] if n == 2
replace treatment = 1 if n == 2

replace point = results[1,9] if n == 1
replace l = results[5,9] if n == 1
replace u = results[6,9] if n == 1
replace treatment = 2 if n == 1

drop if n > 8

twoway (dot  point n if treatment == 1, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  point n if treatment == 2, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(dot  point n if treatment == 3, horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(`a', lcolor(blue)) xline(`b', lpattern(dash) lcolor(black)) xline(`c', lpattern(shortdash)) xlabel(.1 .2 .3 .4 .5 .6 .7 .8 .9)  ///
ylabel(7.5 "Democrats" 4.5 "Independents" 1.5 "Republicans", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment")   size(small) keygap(0) cols(2)) scale(.75) yscale(range(.5 8.5)) ti("Hypothetical Student Loans") saving(hyp_studentloans.gph, replace)

grc1leg2  "hyp_studentloans.gph" "biden_studentloans_party.gph" "hyploan_party.gph" "clintonloan_party.gph", graphregion(color(white)) rows(2) 

* MECHANISMS ANALYSIS *
* Figure 8: Treatment Effects on Perceptions 
* Treatment Effects on Beliefs AND Support *
* Hypothetical Loan  *
use "cyk_mechanisms_survey.dta", replace

gen n = _n
gen bz1 = .
gen u = .
gen l = .
gen bz3 = .
gen treatment = .

logit loan_supp_bin loan_zone1 loan_zone3 gop5 dem5 female age education white rule_of_law 
margins, dydx(loan_zone1) at(loan_zone3=0 gop5=0 dem5=0 female=0 age=45 white=1 rule_of_law=3)
replace bz1 = r(table)[1,1] if n == 1
replace u = r(table)[6,1] if n == 1
replace l = r(table)[5,1] if n == 1
margins, dydx(loan_zone3) at(loan_zone1=0 gop5=0 dem5=0 female=0 age=45 white=1 rule_of_law=3)
replace bz3 = r(table)[1,1] if n == 2
replace u = r(table)[6,1] if n == 2
replace l = r(table)[5,1] if n == 2

reg loan_cong loan_zone1 loan_zone3 gop5 dem5 female age education white rule_of_law 
replace bz1 = r(table)[1,1] if n == 4
replace u = r(table)[6,1] if n == 4
replace l = r(table)[5,1] if n == 4
replace bz3 = r(table)[1,2] if n == 5
replace u = r(table)[6,2] if n == 5
replace l = r(table)[5,2] if n == 5

reg loan_legal loan_zone1 loan_zone3 gop5 dem5 female age education white rule_of_law 
replace bz1 = r(table)[1,1] if n == 7
replace u = r(table)[6,1] if n == 7
replace l = r(table)[5,1] if n == 7
replace bz3 = r(table)[1,2] if n == 8
replace u = r(table)[6,2] if n == 8
replace l = r(table)[5,2] if n == 8

replace n = . if n > 8
recode n (1=1.25) (2=1.75) (4=4.25) (5=4.75) (7=7.25) (8=7.75)

twoway (dot  bz1 n , horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  bz3 n, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(0) ylabel(7.5 "Believe action is legal" 4.5 "Believe Congress supports" 1.5 "Support executive action", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment") size(medsmall) keygap(0) colgap(.5) cols(2)) xlabel(-.4 -.3 -.2 -.1 0 .1 .2 .3 .4)  yscale(range(0 9)) ti("Hypothetical Loan", size(medium)) scale(.8) saving(loan_beliefs.gph, replace)

* Bush Tribunals *
use "cyk_mechanisms_survey.dta", replace

gen n = _n
gen bz1 = .
gen u = .
gen l = .
gen bz3 = .
gen treatment = .

logit trib_supp_bin trib_zone1 trib_zone3 gop5 dem5 female age education white rule_of_law 
margins, dydx(trib_zone1) at(trib_zone3=0 gop5=0 dem5=0 female=0 age=45 white=1 rule_of_law=3)
replace bz1 = r(table)[1,1] if n == 1
replace u = r(table)[6,1] if n == 1
replace l = r(table)[5,1] if n == 1
margins, dydx(trib_zone3) at(trib_zone1=0 gop5=0 dem5=0 female=0 age=45 white=1 rule_of_law=3)
replace bz3 = r(table)[1,1] if n == 2
replace u = r(table)[6,1] if n == 2
replace l = r(table)[5,1] if n == 2

reg trib_cong trib_zone1 trib_zone3 gop5 dem5 female age education white rule_of_law 
replace bz1 = r(table)[1,1] if n == 4
replace u = r(table)[6,1] if n == 4
replace l = r(table)[5,1] if n == 4
replace bz3 = r(table)[1,2] if n == 5
replace u = r(table)[6,2] if n == 5
replace l = r(table)[5,2] if n == 5

reg trib_legal trib_zone1 trib_zone3 gop5 dem5 female age education white rule_of_law 
replace bz1 = r(table)[1,1] if n == 7
replace u = r(table)[6,1] if n == 7
replace l = r(table)[5,1] if n == 7
replace bz3 = r(table)[1,2] if n == 8
replace u = r(table)[6,2] if n == 8
replace l = r(table)[5,2] if n == 8

replace n = . if n > 8
recode n (1=1.25) (2=1.75) (4=4.25) (5=4.75) (7=7.25) (8=7.75)

twoway (dot  bz1 n , horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  bz3 n, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(0) ylabel(7.5 "Believe action is legal" 4.5 "Believe Congress supports" 1.5 "Support executive action", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment") size(medsmall) keygap(0) colgap(.5) cols(2)) xlabel(-.4 -.3 -.2 -.1 0 .1 .2 .3 .4)  yscale(range(0 9)) ti("Bush Tribunals", size(medium)) scale(.8) saving(trib_beliefs.gph, replace)

* Trump Wall *
use "cyk_mechanisms_survey.dta", replace

gen n = _n
gen bz1 = .
gen u = .
gen l = .
gen bz3 = .
gen treatment = .

logit wall_supp_bin wall_zone1 wall_zone3 gop5 dem5 female age education white rule_of_law 
margins, dydx(wall_zone1) at(wall_zone3=0 gop5=0 dem5=0 female=0 age=45 white=1 rule_of_law=3)
replace bz1 = r(table)[1,1] if n == 1
replace u = r(table)[6,1] if n == 1
replace l = r(table)[5,1] if n == 1
margins, dydx(wall_zone3) at(wall_zone1=0 gop5=0 dem5=0 female=0 age=45 white=1 rule_of_law=3)
replace bz3 = r(table)[1,1] if n == 2
replace u = r(table)[6,1] if n == 2
replace l = r(table)[5,1] if n == 2

reg wall_cong wall_zone1 wall_zone3 gop5 dem5 female age education white rule_of_law 
replace bz1 = r(table)[1,1] if n == 4
replace u = r(table)[6,1] if n == 4
replace l = r(table)[5,1] if n == 4
replace bz3 = r(table)[1,2] if n == 5
replace u = r(table)[6,2] if n == 5
replace l = r(table)[5,2] if n == 5

reg wall_legal wall_zone1 wall_zone3 gop5 dem5 female age education white rule_of_law 
replace bz1 = r(table)[1,1] if n == 7
replace u = r(table)[6,1] if n == 7
replace l = r(table)[5,1] if n == 7
replace bz3 = r(table)[1,2] if n == 8
replace u = r(table)[6,2] if n == 8
replace l = r(table)[5,2] if n == 8

replace n = . if n > 8
recode n (1=1.25) (2=1.75) (4=4.25) (5=4.75) (7=7.25) (8=7.75)

twoway (dot  bz1 n , horizontal ndots(0) dcolor(white) symbol(triangle) color(black)) ///
(dot  bz3 n, horizontal ndots(0) dcolor(white) symbol(square) color(black)) ///
(rspike u l n, horizontal color(black)), yti("") graphregion(color(white)) ///
xline(0) ylabel(7.5 "Believe action is legal" 4.5 "Believe Congress supports" 1.5 "Supports executive action", angle(0)) /// 
legend(order( 1 "Zone 1 Treatment" 2 "Zone 3 Treatment") size(medsmall) keygap(0) colgap(.5) cols(2)) xlabel(-.4 -.3 -.2 -.1 0 .1 .2)  yscale(range(0 9)) ti("Trump Wall", size(medium)) scale(.8) saving(wall_beliefs.gph, replace)

grc1leg2 "loan_beliefs.gph" "trib_beliefs.gph" "wall_beliefs.gph", graphregion(color(white)) rows(3) xsize(8.5) ysize(11) 

* Table 3: KHB Method to Explore Mediation *
khb logit trib_supp_bin trib_zone1 trib_zone3 || trib_legal trib_cong, concomitant(gop5 dem5 female education age white rule_of_law) disentangle



